<div class="CartWrap" id="cart-index">
    <{if $is_empty}>
    <{include file="site/cart/cart_empty.html" app=b2c}>
    <{else}>
<div class="CartNav clearfix">
<div class="step stepbj1"><span class="step1"><{t}>购物车<{/t}></span><span class="step2"><{t}>填写订单并确认<{/t}></span><span class="step3"><{t}>成功提交订单<{/t}></span><span class="mycart"><{t}>我的购物车<{/t}></span></div>
</div>
<form id="form-cart" action="<{link app="b2c" ctl="site_cart" act="checkout"}>" method="post" extra="cart">
  <{include file="site/cart/cart_main.html" app=b2c}>
</form>
<{/if}>

<!--
<{if $member_goods && is_array($member_goods)}>
<div class="GoodsSearchWrap MemberMain" id="goodsbody" style="clear:both; float:none; width:950px; margin:5px auto">
  <h3 class="title-bg" style="padding:0">
    <div><{t}>收藏夹里的商品<{/t}><span class="siteparttitle-orage">(<{$member_goods|count}>)</span></div>
  </h3>
  <div class="cart-collect" >
    <table style="z-index:9999" class="picscroll_cart">
      <tr>
        <td class="cart-arrowleft toleft" width="24px"></td>
        <td>
        <div style="width:880px;height:120px;overflow:hidden; clear:both;"> 
        <div style="height:216px;" class="pics-content_cart">
    <{foreach from=$member_goods item=product}>
      <{if !$product.goods_id }><{continue;}><{/if}>
        <dl>
            <dt>
                <div class='cart-product-img' isrc="<{$product.image_default_id|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" ghref='<{link app=b2c ctl=site_product act="index" arg0=$product.goods_id}>' style='width:50px;height:50px;'>
                    <img src='<{$res_url}>/loading.gif'/>
                </div>
            </dt>
            <dd>
              <ul >
                <li style="height:62px">
                    <a href="<{link app=b2c ctl=site_product act=index arg0=$product.goods_id}>" style="color:#09C"><{$product.name}> </a><br /><span class="siteparttitle-orage" style="margin-left:8px"><{$product.price|cur}></span>
                </li>
                </ul>
                <ul class="button">
                  <{if count($product.spec_desc_info)>1}>
<li  style="z-index:<{$zindex}>" >
<a href="<{link app=b2c ctl=site_cart act=addToCart arg0=goods arg1=$product.goods_id arg2=$item.product_id arg3='1' }>" type="g" buy="<{$product.goods_id}>" class="btn-a bulebtn  buy-select " <{if $setting.buytarget == 2}> target="_blank_cart"<{elseif $setting.buytarget == 3}> target="_dialog_minicart"<{/if}> title="<{t}>加入购物车<{/t}>" rel="nofollow" ><i class="has-icon"> <img src='<{$env.app.res_url}>/bundle/shop_icon.gif' /></i><span>加入购物车</span></a>
<{if $showtextbuy}><a class='lnk'><{t}>加入购物车<{/t}></a> <{/if}>
<div class="buy-select-list" style="display:none">
<h3><{if count($product.spec_desc_info) == 0}><{t}>该商品暂时无货<{/t}><{else}><{t}>请选择规格<{/t}><{/if}></h3>
<table width="100%">
<{foreach from=$product.spec_desc_info item=item}>
  <tr>
    <td width="100"><{$item.spec_info}></td>
    <td><span class="fontcolorRed fontbold"><{$item.price|cur_odr:$order.currency}></span></td>
    <td width="100" align="right" style="vertical-align:middle">
    <{if $addcart_disabled != 1}>
        <{if $item.store === null || $item.store - intval($item.freez) > 0}>
      <a type="g" href="<{link app=b2c ctl=site_cart act=addToCart arg0=goods arg1=$product.goods_id arg2=$item.product_id arg3='1'}>" buy="<{$product.goods_id}>" product="<{$product_id}>"<{if $setting.buytarget == 2}> target="_blank_cart"<{elseif $setting.buytarget == 3}> target="_dialog_minicart"<{/if}> title="<{t}>加入购物车<{/t}>" rel="nofollow" class="btnbuy"><{t}>购买<{/t}></a>

      <{else}>
      <a type="g" href="<{link app=b2c ctl=site_product act=gnotify arg0=$product.goods_id arg1=$product_id}>" rel="nofollow" class="btnbuy" title="<{t}>缺货登记<{/t}>"><{t}>缺货<{/t}></a>
<{/if}>

    <{/if}>
    </td>
  </tr>
<{/foreach}>
</table>
</div>
<{else}>
  <{if $addcart_disabled != 1}>

<{foreach from=$product.spec_desc_info item=item}>
        <{if $item.store === null || $item.store - intval($item.freez) > 0}>
    <li>
   <a href="<{link app=b2c ctl=site_cart act=addToCart arg0=goods arg1=$product.goods_id arg2=$item.product_id arg3='1' }>" type="g" buy="<{$product.goods_id}>" class="btn-a bulebtn listact" <{if $setting.buytarget == 2}> target="_blank_cart"<{elseif $setting.buytarget == 3}> target="_dialog_minicart"<{/if}> title="<{t}>加入购物车<{/t}>" rel="nofollow" ><i class="has-icon"> <img src='<{$env.app.res_url}>/bundle/shop_icon.gif' /></i><span>加入购物车</span></a>
    </li>
          <{else}>
            <li>
     <a type="g" href="<{link app=b2c ctl=site_product act=gnotify arg0=$product.goods_id arg1=$product_id}>" rel="nofollow" class="" title="<{t}>缺货登记<{/t}>"><i class="has-icon"> <img src='<{$env.app.res_url}>/bundle/shop_icon.gif' /></i><span>缺货</span></a>
     
    </li>
<{/if}>

<{break;}>
<{/foreach}>


  <{/if}>
<{/if}>
</li>
              </ul>
            </dd>
          </dl>
     <{/foreach}></div>
          </td>
        <td class="cart-arrowright toright" width="24px"></td>
      </tr>
    </table>
    </div>
  </div>
</div>
<{/if}>
-->
<div class="clear"></div>
</div>
<script>
/*
*CartJs update :2009-9-8 11:33:20
*
*@author litie[aita]shopex.cn
*
*------------------------/


/*购物车小图mouseenter效果*/
function thumb_pic(){
  if(!$('goodsbody'))return;
  var cart_product_img_viewer=new Element('div',{styles:{'position':'absolute','zIndex':500,'opacity':0,'border':'1px #666 solid'}}).inject($('goodsbody'));
  var cpiv_show=function(img,event){
       
      if(!img)return;
      cart_product_img_viewer.empty().adopt($(img).clone().removeProperties('width','height').setStyle('border','1px #fff solid')).fade(1);
      
      var size = window.getSize(), scroll = window.getScroll();
        var tip = {x: cart_product_img_viewer.offsetWidth, y: cart_product_img_viewer.offsetHeight};
        var props = {x: 'left', y: 'top'};
        for (var z in props){
            var pos = event.page[z] + 10;
            if ((pos + tip[z] - scroll[z]) > size[z]) pos = event.page[z] - 10 - tip[z];
            cart_product_img_viewer.setStyle(props[z], pos);
        }
  
  };
  
   $ES('#cart-index .cart-product-img').each(function(i){
       new Asset.image(i.get('isrc'),{onload:function(img){
   if(!img)return;
           var _img=img.zoomImg(50,50);
     if(!_img)return;
           _img.setStyle('cursor','pointer').addEvents({
              'mouseenter':function(e){
                 cpiv_show(_img,e);
              },
              'mouseleave':function(e){
                cart_product_img_viewer.fade(0);
              }
           });
           i.empty().adopt(new Element('a',{href:i.get('ghref'),target:'_blank',styles:{border:0}}).adopt(_img));               
       },onerror:function(){
            i.empty();

       }});
   
   });
   
   
};



thumb_pic();


/*购物车处理*/
void function(){
    var cartForm = $('form-cart');
    var cartTotalPanel = $('cartitems');
    Cart=new Object();
    Cart.utility={
        keyCodeFix:[48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,8,9,46,37,39],
        moneyFormat:{
            rule:<{$currency|default:'null'}>,/*evaluate form PHP Smarty*/
            format:function(num){
                var rule = this.rule;
                num = num.toFloat();
                num = num.round(rule.decimals)+'';
                var p =num.indexOf('.');
                if(p<0){
                    p = num.length;
                    part = '';
                }else{
                    part = num.substr(p+1);
                }
                    while(part.length<rule.decimals){
                        part+='0';
                    }
                var c=[];
                while(p>0){
                    if(p>2){
                        c.unshift(num.substr(p-=3,3));
                    }else{
                        c.unshift(num.substr(0,p));
                        break;
                    }
                }
                return rule.sign+c.join(rule.thousands_sep)+rule.dec_point+part;
            }
        }
    };


    $extend(Cart,{
         removeItem:function(handle){
             if(!confirm('<{t}>确认删除？<{/t}>'))return;
             var item = $(handle).getParent('tr');
             var remoteURL = item.get('urlremove');
             item.getFormElements().set('disabled',true);
             this.updateTotal(remoteURL,{
             onRequest:function(){
                if(!window.ie6){
                     item.getFirst().set({'html':'<{t}>正在删除...<{/t}>'});
                     item.setStyles({'background':'#FBE3E4','opacity':1})
                }
             },
             onComplete:function(){
                if(!window.ie6){
                return new Fx.Style(item,'opacity').start(0).chain(function(){
                           var el=this.element;
                           if(el.hasClass('havechild')){
                               var chlid_id= el.get('chlid_id'); 
                               if(group=$ES('.'+chlid_id,item.getParent('table')))
                               group.each(function(ell){ell.remove();});
                           }
                           el.remove();
                           $$('.cart-number').set('text',Cookie.get('S[CART_COUNT]')||0);
                           /*购物车删除操作到极限时,刷新购物车页*/
                           /*if(!$$('#cartItems tr[urlremove]').length){location.reload();}*/
                       });
                 }
                 item.remove();
                 $$('.cart-number').set('text',Cookie.get('S[CART_COUNT]')||0);
             }});
         },
         ItemNumUpdate:function(numInput,num,evt){
			 
              var _float_store = numInput.getParent('tr').getAttribute('floatstore').toInt();
              var type=['toFloat','toInt'];

			  var forUpNum=numInput.value[type[_float_store]]();
          
              if(evt&&new Event(evt).target!=numInput){
                 forUpNum = (isNaN(forUpNum)?1:forUpNum)+num;
              }

             if(forUpNum[type[_float_store]]()<=0)forUpNum=1;

              numInput.value = forUpNum.limit(1,Number.MAX_VALUE);
              
              
              var _goods_number = numInput.getParent('tr').getAttribute('number')[type[_float_store]]();
         
             
              this.updateItem(numInput,numInput.getParent('tr'));
              if(forUpNum > _goods_number) {
                //numInput.value = _goods_number;
                MessageBox.error('<{t}>数量错误！<{/t}><br/>' + numInput.getParent('tr').getAttribute('g_name') + "<{t}>(可购买数量为：<{/t}>" + _goods_number + ") " );return false;
              }
         },
         updateItem:function(input,item){
		
             if(input.value=='NaN') { input.value=1;return false;}
             item.retrieve('request',{cancel:$empty}).cancel();
          
             item.store('request',new Request({
				url:item.get('urlupdate'),
				data:input.getParent('tr'),
				method:'post',
				onSuccess:function(res){
					 $('cart-ajax-update').set('html', res);
					 this.updateNum(input); 
				 }.bind(this),
				onFailure:function(xhr){
					 input.focus();
					 input.value = item.get('buy_store');
					 MessageBox.error("<{t}>商品库存不足!<{/t}>");
				 }.bind(this)
			 }).send());
         },
         updateNum:function(input){
                 var item=input.getParent('tr'),json;
                 if( !$('update-ajax-num') ) {
                   // item.remove();
				   return false;
                 }else{
                 	json=JSON.decode($('update-ajax-num').value);
                 }
                 item.getElements('h6').set('html',$('update-ajax-num').get('error_msg'));
               
                 item.set('buy_store',input.value);
                 ['buy_price','consume_score'].each(function(str,i){
                         if(json){
                              var el=$E('.'+str,item);
                              el.set('text',json[str]);  
                         }
                 });
         },
         updateTotal:function(remoteURL,options){
            options = options||{};
            new Request.HTML($extend({update:$('cart-ajax-update'),'method':'post',url:remoteURL,data:$('form-cart')},options)).send();
         },
         empty:function(remoteURL){
            if(!confirm('<{t}>确认清空购物车？<{/t}>'))return;
            new Request({
				url:remoteURL,
                onRequest:function(){
                   MessageBox.success('<{t}>清空购物车成功,正在准备刷新本页<{/t}>');
                },
                onComplete:function(){
                    location.href=location.href;
                }
            }).post();
         }
    });

if($('cart-items'))
    $ES('#form-cart').getLast('div').addEvents({
        'mousedown':function(e){
            var target=$(e.target);
            if(target.hasClass('numadjust'))
            target.addClass('active');
         },
        'mouseup':function(e){
            var target=$(e.target);
            if(target.hasClass('numadjust'))
            target.removeClass('active')
        },
        'keydown':function(e){
            var target=$(e.target);
            if(target.hasClass('textcenter')){
                if(target.getParent('tr').getAttribute('floatstore').toInt()==1) {
                    if(e.code==110) e.code=48; //小数
                    if(e.code==190) e.code=48;
                }
                if(!Cart.utility.keyCodeFix.contains(e.code)){e.stop();}
            }
         },
       /* 'change':function(e){
            var target=$(e.target);
            if(target.hasClass('textcenter')){
                Cart.ItemNumUpdate(target,target.value);
            }
         },*/
        'click':function(e){
            var target=$(e.target);
            if(target.hasClass('numadjust')){               
                var num=target.hasClass('increase')?1:-1;
                var ipt=target.getPrevious('input');
                Cart.ItemNumUpdate(ipt,num,e);
            }
            if(e.target.hasClass('delItem')){
                Cart.removeItem(target)
            }
        }
    });

}();
</script>
<script>
    /*
    收藏夹滚动播放
    
       new Switchable($E('.picscroll_cart'), {
            effect: 'scrollx',
            autoplay:false,
            steps: 4,
            prev:'.toleft',
            next:'.toright',
            hasTriggers:false,
            viewSize: [880,216],
            content:'.pics-content_cart',   
            panels:'dl[img_id]',
            circular: false,  
            haslrbtn:true,
            disableCls: 'disable',
            lazyDataType: 'img',
            onInit:function(){
                if(window.ie6){
                       var wid = $E('.pics-content_cart').getStyle('width');
                       $E('.pics-content_cart').setStyle('width',parseInt(wid)+100);
                }
            }
        });
        
        

          
          
          $$('.GoodsSearchWrap .buy-select').each(function(el){
              el.removeEvent('mouseover').addEvent('mouseover',function(e):w
                alert(123);
                var pos = $(e.target).getCoordinates();
            new Element('div',{'html':$(e.target.getNext('.buy-select-list').innerHTML})).inject(document.body);
            alert(pos.left);
    })}); 
  */     
</script>

<{script src='goodscupcake.js' app='b2c'}>
